import { getCategoryList, reqGetBannerList, reqGetFloorInfo } from "@/api"

const state = {
    count: 1,
    categoryList:[],
    bannerList:[],
    floorInfo:[],
}
const mutations = {
    GETCATEGORYLIST(state,categoryList){
        state.categoryList = categoryList
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList = bannerList
    },
    GETFLOORINFO(state,floorInfo) {
        state.floorInfo = floorInfo
    }
}
const actions = {
    async getCategoryList({commit}) {
        let result = await getCategoryList()
        if(result.code == 200){
            commit("GETCATEGORYLIST",result.data)
        }   
    },
    // 获取首页轮播图的数据
    async getBannerList({commit}){
        let result = await reqGetBannerList()
        //console.log(result)
        if(result.code == 200) {
            commit("GETBANNERLIST",result.data)
        }
    },
    // 获取floor数据
    async getFloorInfo({commit}){
        let result = await reqGetFloorInfo()
        if(result.code == 200) {
            commit("GETFLOORINFO",result.data)
        }
    }
}
const getters = {

}

export default {
    state,
    mutations,
    actions,
    getters
}